package com.mydemo.springlearning.functions.CRUDdemo.byxml.controller;

import com.mydemo.springlearning.functions.CRUDdemo.entity.User;
import com.mydemo.springlearning.functions.CRUDdemo.byxml.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author hd
 * @date 2022/2/8 15:44
 */
@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("list")
    public String list(Model model) {
        final List<User> users = userService.getAllUsers();
        model.addAttribute("users", users);
        return "user-test";
    }

}
